home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / buddy / sampdb.frm < prev    next >
Text File  |  1996-04-16  |  9KB  |  282 lines

  1. VERSION 4.00
  2. Begin VB.Form DynamicRecordSet 
  3.    Caption         =   "DynamicRecordSet"
  4.    ClientHeight    =   7116
  5.    ClientLeft      =   876
  6.    ClientTop       =   1524
  7.    ClientWidth     =   5796
  8.    BeginProperty Font 
  9.       name            =   "Arial"
  10.       charset         =   0
  11.       weight          =   700
  12.       size            =   7.8
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   7440
  18.    Left            =   828
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   7116
  21.    ScaleWidth      =   5796
  22.    Top             =   1248
  23.    Width           =   5892
  24.    Begin VB.CommandButton btnRecSetNamePrevious 
  25.       Caption         =   "τ"
  26.       BeginProperty Font 
  27.          name            =   "Wingdings"
  28.          charset         =   2
  29.          weight          =   700
  30.          size            =   18
  31.          underline       =   0   'False
  32.          italic          =   0   'False
  33.          strikethrough   =   0   'False
  34.       EndProperty
  35.       Height          =   540
  36.       Left            =   1548
  37.       TabIndex        =   4
  38.       Top             =   6468
  39.       Width           =   925
  40.    End
  41.    Begin VB.CommandButton btnRecSetNameLast 
  42.       Caption         =   "Φƒ"
  43.       BeginProperty Font 
  44.          name            =   "Wingdings"
  45.          charset         =   2
  46.          weight          =   700
  47.          size            =   18
  48.          underline       =   0   'False
  49.          italic          =   0   'False
  50.          strikethrough   =   0   'False
  51.       EndProperty
  52.       Height          =   540
  53.       Left            =   4056
  54.       TabIndex        =   3
  55.       Top             =   6468
  56.       Width           =   925
  57.    End
  58.    Begin VB.CommandButton btnRecSetNameNext 
  59.       Caption         =   "Φ"
  60.       BeginProperty Font 
  61.          name            =   "Wingdings"
  62.          charset         =   2
  63.          weight          =   700
  64.          size            =   18
  65.          underline       =   0   'False
  66.          italic          =   0   'False
  67.          strikethrough   =   0   'False
  68.       EndProperty
  69.       Height          =   540
  70.       Left            =   2928
  71.       TabIndex        =   2
  72.       Top             =   6468
  73.       Width           =   925
  74.    End
  75.    Begin VB.CommandButton btnRecSetNameFirst 
  76.       Caption         =   "ƒτ"
  77.       BeginProperty Font 
  78.          name            =   "Wingdings"
  79.          charset         =   2
  80.          weight          =   700
  81.          size            =   18
  82.          underline       =   0   'False
  83.          italic          =   0   'False
  84.          strikethrough   =   0   'False
  85.       EndProperty
  86.       Height          =   540
  87.       Left            =   480
  88.       TabIndex        =   1
  89.       Top             =   6468
  90.       Width           =   925
  91.    End
  92.    Begin VB.TextBox txtName 
  93.       BeginProperty Font 
  94.          name            =   "Arial"
  95.          charset         =   0
  96.          weight          =   400
  97.          size            =   7.8
  98.          underline       =   0   'False
  99.          italic          =   0   'False
  100.          strikethrough   =   0   'False
  101.       EndProperty
  102.       Height          =   300
  103.       Index           =   0
  104.       Left            =   2232
  105.       TabIndex        =   0
  106.       Text            =   "txtName"
  107.       Top             =   408
  108.       Width           =   3396
  109.    End
  110.    Begin VB.Label lblName 
  111.       Alignment       =   1  'Right Justify
  112.       Caption         =   "lblName"
  113.       Height          =   312
  114.       Index           =   0
  115.       Left            =   84
  116.       TabIndex        =   5
  117.       Top             =   408
  118.       Width           =   2028
  119.    End
  120. End
  121. Attribute VB_Name = "DynamicRecordSet"
  122. Attribute VB_Creatable = False
  123. Attribute VB_Exposed = False
  124. Public dbDatabase As Database
  125. Public rsRecSetName As Recordset
  126. Public Sub A_ReadMe()
  127. 'This template is designed for use with the RAD-Copy Buddy.
  128. '
  129. 'Purpose:   This template provides Recordset navigation
  130. '           buttons along with all supporting procedures.
  131. '
  132. 'Usage:     1) Change {{RecSetName}} to desired RecordSet
  133. '              variable name
  134. '           2) RAD-Copy all 4 Command Buttons and txtName
  135. '              to desired form.
  136. '           3) RAD-Copy Declarations, {{RecSetName}}ButtonStatus,
  137. '              and {{RecSetName}}Populate to desired form.
  138. '           4) On the target form, Copy/Paste txtName to create a
  139. '              ControlArray with as many Textboxes as there will be
  140. '              columns returned by your recordset.
  141. '           5) Or, RAD-Copy and call {{RecSetName}}CreateControls
  142. '              to dynamically create Labels and Textboxes for
  143. '              Recordset fields at run time.
  144. '           6) You can modify {{RecSetName}}Populate as indicated to
  145. '              bypass text box display or perform custom DB processing.
  146. '           7) Code the target form to initialize rs{{RecSetName}}
  147. '              and dbDatabase (See Sample_Form_Load).
  148. '
  149. 'Comments:  These templates support fields that can be displayed
  150. '           as text only.  Template does not include routines
  151. '           for database updates.
  152. '
  153. 'Tags:
  154. '{{RecSetName}}
  155. End Sub
  156. Public Sub RecSetNameCreateControls()
  157. '** Dynamically create controls and labels from the
  158. '** rsRecSetName to display fields.
  159. '
  160.     Dim nColCount As Integer
  161.     Dim nTop As Integer
  162. '
  163. '** Verify #of columns and initialize primary Controls
  164.     If rsRecSetName.Fields.Count > 0 Then
  165.         txtName(0).Text = ""
  166.         lblName(0).Caption = rsRecSetName.Fields(0).Name
  167.         nTop = txtName(0).Top
  168.     End If
  169. '
  170. '** Loop thru remaining Fields and initialize controls
  171.     For nColCount = 1 To rsRecSetName.Fields.Count - 1
  172. '
  173.         Load txtName(nColCount)
  174.         Load lblName(nColCount)
  175. '
  176.         '** Calculate top independent of scale
  177.         nTop = nTop + txtName(nColCount).Height * 1.2
  178. '
  179.         txtName(nColCount).Text = ""
  180.         txtName(nColCount).Top = nTop
  181.         lblName(nColCount).Caption = rsRecSetName.Fields(nColCount).Name
  182.         lblName(nColCount).Top = nTop
  183.         txtName(nColCount).Visible = True
  184.         lblName(nColCount).Visible = True
  185. '
  186.     Next nColCount
  187.     Exit Sub
  188. '
  189. End Sub
  190. Private Sub RecSetNameButtonStatus()
  191. '** Set Visible based on record position
  192. '
  193.     If rsRecSetName.AbsolutePosition = 1 Then
  194.         btnRecSetNamePrevious.Visible = False
  195.     Else
  196.         btnRecSetNamePrevious.Visible = True
  197.     End If
  198. '
  199.     If rsRecSetName.EOF Then
  200.         btnRecSetNameNext.Visible = False
  201.     Else
  202.         btnRecSetNameNext.Visible = True
  203.     End If
  204. '
  205. End Sub
  206.  
  207. Public Sub RecSetNamePopulate()
  208.     Dim nColCount As Integer
  209.     Dim vReturnRows As Variant
  210.     Dim vReturnValue As Variant
  211. '
  212. '** Return array of current row's field values
  213.     vReturnRows = rsRecSetName.GetRows(1)
  214. '
  215. '** Populate TextBoxes.  If you do not want to use the
  216. '** standard text boxes, insert your processing of the
  217. '** vReturnRows array of returned fields here:
  218.     For nColCount = 0 To rsRecSetName.Fields.Count - 1
  219.         vReturnValue = vReturnRows(nColCount, 0)
  220.         If Not IsNull(vReturnValue) Then
  221.             txtName(nColCount).Text = CStr(vReturnValue)
  222.         Else
  223.             txtName(nColCount).Text = ""
  224.         End If
  225.     Next nColCount
  226. '
  227.     Exit Sub
  228. '
  229. End Sub
  230.  
  231. Private Sub btnRecSetNameLast_Click()
  232. '
  233.     rsRecSetName.MoveLast
  234.     RecSetNamePopulate
  235.     RecSetNameButtonStatus
  236.     Exit Sub
  237. '
  238. End Sub
  239. Private Sub btnRecSetNameFirst_Click()
  240. '
  241.     rsRecSetName.MoveFirst
  242.     RecSetNamePopulate
  243.     RecSetNameButtonStatus
  244.     Exit Sub
  245. '
  246. End Sub
  247. Private Sub btnRecSetNameNext_Click()
  248. '
  249.     If Not rsRecSetName.EOF Then
  250.         RecSetNamePopulate
  251.     End If
  252.     RecSetNameButtonStatus
  253.     Exit Sub
  254. '
  255. End Sub
  256.  
  257. Private Sub btnRecSetNamePrevious_Click()
  258. '
  259.     If Not rsRecSetName.BOF Then
  260.         rsRecSetName.MovePrevious
  261.         rsRecSetName.MovePrevious
  262.         RecSetNamePopulate
  263.     End If
  264.     RecSetNameButtonStatus
  265.     Exit Sub
  266. '
  267. End Sub
  268.  
  269. Private Sub Sample_Form_Load()
  270. '** Here is a